{% load static %}
<!doctype html>
<html lang="en">

<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
	<!-- <link rel="icon" href="../../../../favicon.ico"> -->
	<title>Soda cap</title>
	<link href="{% static 'Znd_class/css/bootstrap.min.css' %}" rel="stylesheet">
	<link href="{% static 'Znd_class/css/signin.css' %}" rel="stylesheet">
</head>

<body class="text-center">
	<form id="signin_form" class="form-signin">
		<h1 class="h1 mb-3 font-weight-normal">Soda cap</h1> <br>
		{% csrf_token %}
		<label for="inputUsername" class="sr-only">Username</label>
		<input type="text" id="inputUsername" name="username" class="form-control" placeholder="Username" required autofocus>
		<label for="inputPassword" class="sr-only">Password</label>
		<input type="password" id="inputPassword" name="password" class="form-control" placeholder="Password" required> <br>
		<button id="signin_btn" class="btn btn-lg btn-primary btn-block" type="button">Sign in</button>
		<p class="mt-5 mb-3 text-muted">&copy; 2019</p>
	</form>

	<script src="{% static 'Znd_class/js/jquery.min.js' %}"></script>
	<script>
		$('#signin_btn').click(function () {
			$.ajax({
				type: 'post',
				dataType: 'json',
				url: "{% url 'Znd_class:signin' %}",
				data: $('#signin_form').serialize(),
				contentType: "application/x-www-form-urlencoded",
				success: function (data) {
					if (data.status == 21) {
						alert(data.msg)
					}
					location.replace(data.url)
				}
			})
		})
	</script>
</body>

</html>